{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">附件管理</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
        <script type="text/html" id="barTool">
            <a href='{:url("del")}?ids={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del"><i class="layui-icon layui-icon-delete"></i></a>
        </script>
    </div>
</div>
<script type="text/html" id="picTpl">
    {{#  if(d.mime.indexOf("image") > -1){ }}
    <img style="max-width:80px; max-height:30px;" src="{{d.path}}" data-image="{{d.name}}">
    {{#  } else { }}
    <img style="max-width:80px; max-height:30px;" src="{:url('admin/ajax/icon')}?suffix={{d.ext}}">
    {{#  } }}
</script>
{/block}
{block name="script"}
<script>
    layui.use('yznTable', function() {
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            delete_url: '{:url("del")}',
        };

        table.render({
            init: init,
            id: 'dataTable',
            toolbar: ['refresh','delete'],
            elem: '#dataTable',
            url: '{:url("index")}',
            cols: [
                [
                    { type: 'checkbox', fixed: 'left' },
                    { field: 'id', width: 80, title: 'ID', sort: true },
                    { field: 'aid', width: 80, title: '用户ID' },
                    { field: 'name', title: '名称' },
                    { field: 'path', width: 100, align: "center",title: '图片', search: false, templet: '#picTpl' },
                    { field: 'path', width: 450, align: "center", title: '物理路径', templet: '<div><a class="layui-btn layui-btn layui-btn-xs" href="{{d.path}}" target="_blank">{{d.path}}</a></div>' },
                    { field: 'size', width: 100, title: '大小', sort: true },
                    { field: 'ext', width: 100, title: '类型' },
                    { field: 'mime', width: 120, title: 'Mime类型' },
                    { field: 'driver', width: 100, title: '存储引擎' },
                    { field: 'create_time', width: 180, title: '上传时间', search: 'range' },
                    { fixed: 'right', width: 70, title: '操作', toolbar: '#barTool' }
                ]
            ],
            page: {}
        });
    });
</script>
{/block}